package com.tuanzi.loan.business.service.statistics.impl;

import com.tuanzi.loan.business.entity.statistics.LoanAdsChannelDetail;
import com.tuanzi.loan.business.repository.statistics.LoanAdsChannelDetailRepository;
import com.tuanzi.loan.business.service.statistics.LoanAdsChannelDetailService;
import com.tuanzi.loan.core.aspect.Debug;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.retry.RetryException;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Simon
 * @date 2019/07/29 14:29
 */
@Slf4j
@Debug
@Service
@Transactional
@Retryable(value = {RetryException.class})
public class LoanAdsChannelDetailServiceimpl implements LoanAdsChannelDetailService {

    @Autowired
    private LoanAdsChannelDetailRepository loanAdsChannelDetailRepository;

    public void updateAccessToken(String channelCode, String accessToken) {
        loanAdsChannelDetailRepository.updateAccessToken(channelCode,accessToken);
    }

    public void insert(LoanAdsChannelDetail loanAdsChannelDetail) {
        loanAdsChannelDetailRepository.insert(loanAdsChannelDetail);
    }

    public List<LoanAdsChannelDetail> findAll(Integer adsPlatformType) {
        return loanAdsChannelDetailRepository.findAll(adsPlatformType);
    }
    public List<LoanAdsChannelDetail> findAllChannel() {
        return loanAdsChannelDetailRepository.findAllChannel();
    }

    public LoanAdsChannelDetail findByChannel(String channelCode) {
        return loanAdsChannelDetailRepository.findByChannel(channelCode);
    }
}
